package ac.il.technion.cs236369.hw5.core.bean;

import java.util.Date;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import ac.il.technion.cs236369.hw5.core.entities.User;

public class CheckDisabledBean {

	private String userLogin;
	
	private boolean isDisabled;

	public String getUserLogin( ) {
		return userLogin;
	}

	public void setUserLogin( String userLogin) {
		this.userLogin = userLogin;
		EntityManagerFactory emf = Persistence.createEntityManagerFactory( "jpaProvider");
		EntityManager manager = emf.createEntityManager( );
		User user = manager.find( User.class, userLogin);
		if ( user != null) {
			isDisabled = user.getActivityStatus( ).before( new Date( ));
		}
	}

	public boolean isDisabled( ) {
		return isDisabled;
	}
	
}
